import { defineComponent } from 'vue'
import { useUserStore } from '@/store/modules/user'

export default defineComponent({
  name: 'Home',
  setup() {
    const userStore = useUserStore()
    const handleLogout = () => {
      userStore.logout()
    }
    return () => {
      const content = userStore.token ? (
        <div>
          <div class="mb-5" onClick={handleLogout}>
            用户Token: {userStore.token}
          </div>
          <a-button type="primary" danger onClick={handleLogout}>
            <i class="fas fa-sign-out-alt"></i> 登出
          </a-button>
        </div>
      ) : (
        <div>
          <div class="mb-5">用户未登录</div>
          <div class="block">
            <router-link to="/login">
              <a-button type="primary">
                <i class="fas fa-hand-point-up"></i> 点击登录
              </a-button>
            </router-link>
          </div>
        </div>
      )
      return (
        <div class="h-screen flex-center text-xl text-center">{content}</div>
      )
    }
  }
})
